package com.umer.pinban.scan.adapter;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.common.ui.recycleview.adapter.RecyclerviewBasicAdapter;
import com.common.ui.recycleview.base.ViewHolder;
import com.common.ui.recycleview.listener.OptListener;
import com.common.utils.Constants;
import com.facebook.drawee.view.SimpleDraweeView;
import com.umer.pinban.R;
import com.umer.pinban.bean.customer.CommodityListBean;

import java.util.List;

public class ScanCustomerProjectJiaGouMaiAdapter extends RecyclerviewBasicAdapter<CommodityListBean> {

    private OptListener optListener;

    public ScanCustomerProjectJiaGouMaiAdapter(Context context, List<CommodityListBean> datas, int layoutId,
                                               OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
    }

    @Override
    public void convert(ViewHolder holder, final CommodityListBean commodityListBean, final int position) {
        /*LinearLayout select_jishi_jiagou = holder.getView(R.id.select_jishi_jiagou);
        SimpleDraweeView simpleDraweeView =  holder.getView(R.id.iv_jiagou);
        TextView tv1 =  holder.getView(R.id.tv1_jiagou);
        TextView tv2 =  holder.getView(R.id.tv2_jiagou);
        TextView tv3 =  holder.getView(R.id.tv2_jiagou_count);
        ImageView iv_xiugai = holder.getView(R.id.iv_xiugai);
        TextView tv_name = holder.getView(R.id.tv_name);
        String name = commodityListBean.getJishiName();
        if(TextUtils.isEmpty(name)){
            tv_name.setText("选择优美师");
        }else {
            tv_name.setText(name);
        }
        tv1.setText(commodityListBean.getName());
        tv2.setText("¥"+commodityListBean.getPrice());
        tv3.setText("x"+commodityListBean.getCount2());
        final String path = commodityListBean.getFilePath();
        if(!TextUtils.isEmpty(path)){
            Uri uri = Uri.parse(Constants.IP_PORT_DEFAULT_PICTURE+path);
            simpleDraweeView.setImageURI(uri);
        }else {
            Uri uri = Uri.parse("");
            simpleDraweeView.setImageURI(uri);
        }

        select_jishi_jiagou.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });

        iv_xiugai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });*/
    }
}
